home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-16 | 1.1 KB | 63 lines | [TEXT/CWIE] |
- #include "ISpPPTestTools.h"
-
- void UInt32ToHexBytes(UInt32 number, unsigned char *bytes)
- {
- UInt32 mask = 0xf0000000;
- int itr;
-
-
- for(itr = 0; itr < 8; itr++)
- {
- UInt32 digit = number & mask;
- digit = digit >> (4 * (7 - itr));
-
- char theChar;
-
- if ((digit >= 0) && (digit <= 9))
- {
- theChar = '0' + digit;
- }
- else if ((digit >= 10) && (digit <= 15))
- {
- theChar = 'a' + digit - 10;
- }
- else
- {
- theChar ='?';
- }
-
- *bytes = theChar;
- bytes++;
-
- mask = mask >> 4;
- }
- }
-
- void UInt32ToHexString(UInt32 number, Str255 theString)
- {
- theString[0] = 10;
- theString[1] = '0';
- theString[2] = 'x';
-
- UInt32ToHexBytes(number, &(theString[3]));
- }
-
- void UnsignedWideToHexString(const UnsignedWide &number, Str255 theString)
- {
- theString[0] = 18;
- theString[1] = '0';
- theString[2] = 'x';
-
- UInt32ToHexBytes(number.hi, &(theString[3]));
- UInt32ToHexBytes(number.lo, &(theString[11]));
- }
-
- void UInt32ToFourByte(UInt32 number, Str255 theString)
- {
- theString[0] = 4;
- theString[1] = (number & 0xff000000) >> 24;
- theString[2] = (number & 0x00ff0000) >> 16;
- theString[3] = (number & 0x0000ff00) >> 8;
- theString[4] = (number & 0x000000ff) >> 0;
- }
-